package com.itheima.mapper.sms;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.itheima.vo.pojo.SmsFlashPromotion;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Update;

@Mapper
public interface SmsFlashPromotionMapper extends BaseMapper<SmsFlashPromotion> {

    @Update("update sms_flash_promotion\n" +
            "    set title = #{title},\n" +
            "      start_date = #{startDate},\n" +
            "      end_date = #{endDate},\n" +
            "      status = #{status},\n" +
            "      create_time = #{createTime}\n" +
            "    where id = #{id} ")
    void update(SmsFlashPromotion smsFlashPromotion);


    //修改线上线下的状态
    @Update("<script> " +
            "update sms_flash_promotion set " +
            "<if test='title!=null'> title = #{title},</if>" +
            "<if test='startDate!=null'> startDate=#{startDate} ,</if>\n" +
            "<if test='endDate!=null'> endDate=#{endDate} ,</if>\n" +
            "<if test='status!=null'> status=#{status}, </if>" +
            "<if test='createTime!=null'> createTime=#{createTime},</if> " +
            "id = #{id} where id = #{id} " +
            "</script>")
    void updateStatus(SmsFlashPromotion smsFlashPromotion);
}
